package com.compression.tool.ui;

import javax.swing.*;
import java.awt.*;

/**
 * @author 自然醒
 * @version 1.0
 */
// 主界面
public class MainFrame extends JFrame {
    private JTabbedPane tabbedPane; // 选项卡面板
    private BatchProcessorPanel batchProcessorPanel; // 批量处理面板
    private FilePreviewPanel filePreviewPanel; // 文件预览面板
    private CompressionOptionPanel compressionOptionPanel; // 压缩选项面板

    public MainFrame() {
        setTitle("文件压缩工具");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // 根据屏幕尺寸自动调整
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int width = (int) (screenSize.width * 0.7); // 屏幕宽度的70%
        int height = (int) (screenSize.height * 0.75); // 屏幕高度的75%
        setSize(width, height);

        setLocationRelativeTo(null);
        setMinimumSize(new Dimension(800, 600));

        initComponents();
        layoutComponents();
    }

    private void initComponents() {
        tabbedPane = new JTabbedPane();
        batchProcessorPanel = new BatchProcessorPanel();
        filePreviewPanel = new FilePreviewPanel();
        compressionOptionPanel = new CompressionOptionPanel();
    }

    private void layoutComponents() {
        // 创建主面板
        JPanel mainPanel = new JPanel(new BorderLayout());

        // 添加标签页
        tabbedPane.addTab("文件操作", compressionOptionPanel);
        tabbedPane.addTab("文件预览", filePreviewPanel);
        tabbedPane.addTab("批量处理", batchProcessorPanel);

        mainPanel.add(tabbedPane, BorderLayout.CENTER);

        // 添加状态栏
        JPanel statusPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        statusPanel.add(new JLabel("就绪"));
        mainPanel.add(statusPanel, BorderLayout.SOUTH);

        setContentPane(mainPanel);
    }


}
